package cn.szq.springframework.test.common;

import cn.szq.springframework.beans.BeansException;
import cn.szq.springframework.beans.factory.config.BeanPostProcessor;
import cn.szq.springframework.test.bean.UserService;

/***
 * All rights Reserved, Designed By www.jx-lab.com
 * @Title: MyBeanPostProcessor
 * @Description:
 * @author lixy
 * @date 2021/8/16 15:11
 * @version V1.0
 * @Copyright: www.jx-lab.com Inc. All rights reserved.
 * 注意：本内容仅限于众合景轩信息技术有限公司内部传阅，禁止外泄以及用于其他的商业目
 */
public class MyBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if ("userService".equals(beanName)){
            UserService userService = (UserService) bean;
            userService.setLocation("改为：北京");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }
}
